import request from '../utils/request'

const dev = false
const devURL = 'http://192.168.2.117:8080/stemcell'
const proURL = 'http://112.74.80.87:8080/stemcell'
// const proURL = 'http://www.zadd.xyz/stemcell'

export const URL = dev ? devURL : proURL
export const URL2 = 'http://www.zadd.xyz/stemcell'

const api = {
  // 登录
  login (fromData) {
    return request(`${URL}/front/member/loginFront`, {
      method: 'POST',
      body: fromData
    })
  },
  // 注册
  register (fromData) {
    return request(`${URL}/front/member/registerFront`, {
      method: 'POST',
      body: fromData
    })
  },
  // 查询会员手机号是否存在
  findMemberPhone (phone) {
    return request(`${URL}/front/member/findMemberPhone/${phone}`)
  },
  // 查询会员邮箱是否存在
  findMemberEmail (email) {
    return request(`${URL}/front/member/findMemberEmail?email=${email}`)
  },
  // 发送手机验证码
  sendPhoneCode (phone) {
    return request(`${URL}/front/member/sendPhoneCode?phone=${phone}`)
  },
  // 发送邮箱验证码
  sendMailCode (email) {
    return request(`${URL}/front/member/sendMailCode?email=${email}`)
  },
  // 通过手机号修改密码
  updatePhonePw (fromData) {
    return request(`${URL}/front/member/updateMemberPasswrodByPhone`, {
      method: 'POST',
      body: fromData
    })
  },
  // 通过邮箱修改密码
  updateEmailPw (fromData) {
    return request(`${URL}/front/member/updateMemberPasswrodByEmail`, {
      method: 'POST',
      body: fromData
    })
  },
  // 获取全部新闻
  findAllNews () {
    return request(`${URL}/front/news/findAllNews`)
  },
  // 获取全部新闻
  findNewsById (id) {
    return request(`${URL}/front/news/findNewsById/${id}`)
  },
  // 根据新闻类型查询新闻
  findNewsByFlag (flag) {
    return request(`${URL}/front/news/findNewsByFlag/${flag}`)
  },
  // 查询全部集团分支信息
  findAllBranchOffice () {
    return request(`${URL}/front/branchOffice/findAllBranchOffice`)
  },
  // 查询指定集团分支信息
  findBranchOfficeById (id) {
    return request(`${URL}/front/branchOffice/findBranchOfficeById/${id}`)
  },
  // 轮播图
  findAllPic () {
    return request(`${URL}/front/pic/findAllPic`)
  }
}
export default api
